
import { gameHelper } from '../../utils/GameHelpler';
const { ccclass, property, requireComponent, menu } = cc._decorator;
/**
 * 合并的各个组件方便进行类似2.x的tween属性缓动操控
 */

@ccclass
@menu('cccframework/Props')
// @requireComponent(Sprite)
export class Props extends cc.Component {

    onLoad() {
        this.requireComps();
    }
    requireComps() {
    }

    tweenCache: cc.Tween[] = []

    /**color */
    @property({ type: cc.Color })
    get color(): cc.Color {
        return this.node.color;
    }
    set color(v: cc.Color) {
        this.node.color = v;
    }

    @property({ type: cc.Float })
    get anchorX(): number {
        return this.node.anchorX;
    }
    set anchorX(v: number) {
        this.node.anchorX = v;
    }
    @property({ type: cc.Float })
    get anchorY(): number {
        return this.node.anchorY;
    }
    set anchorY(v: number) {
        this.node.anchorY = v;
    }

    /**width */
    @property({ type: cc.Float })
    get width(): number {
        return this.node.width;
    }
    set width(v: number) {
        this.node.width = v;
    }
    /**height */
    @property({ type: cc.Float })
    get height(): number {
        return this.node.height;
    }
    set height(v: number) {
        this.node.height = v;
    }

    /**opacity */
    @property({ type: cc.Integer })
    get opacity(): number {
        return this.node.opacity;
    }
    set opacity(v: number) {
        this.node.opacity = v;
    }

    /**x */
    @property({ type: cc.Float })
    get x(): number {
        return this.node.x;
    }
    set x(v: number) {
        this.node.x = v;
    }
    /**y */
    @property({ type: cc.Float })
    get y(): number {
        return this.node.y;
    }
    set y(v: number) {
        this.node.y = v;
    }
    /**position */
    @property({ type: cc.Vec2 })
    get position(): cc.Vec2 {
        return this.node.getPosition();
    }
    set position(v: cc.Vec2) {
        this.node.setPosition(v);
    }

    /**worldX */
    @property({ type: cc.Float })
    get worldX(): number {
        return this.node.worldX;
    }
    set worldX(v: number) {
        this.node.worldX = v;
    }
    /**worldY */
    @property({ type: cc.Float })
    get worldY(): number {
        return this.node.worldY;
    }
    set worldY(v: number) {
        this.node.worldY = v;
    }
    /**worldPosition */
    @property({ type: cc.Vec2 })
    get worldPosition(): cc.Vec2 {
        return this.node.worldPosition;
    }
    set worldPosition(v: cc.Vec2) {
        this.node.worldPosition = v;
    }
    /**scale */
    @property({ type: cc.Float })
    get scale(): number {
        return this.node.scale;
    }
    set scale(v: number) {
        this.node.scale = v;
    }
    /**scale */
    @property({ type: cc.Integer })
    get scaleX(): number {
        return this.scaleX;
    }
    set scaleX(v: number) {
        this.node.scaleX = v;
    }
    /**scaleY */
    @property({ type: cc.Integer })
    get scaleY(): number {
        return this.scaleY;
    }
    set scaleY(v: number) {
        this.node.scaleY = v;
    }

    /**angle */
    @property({ type: cc.Integer })
    get angle(): number {
        return this.node.angle;
    }
    set angle(v: number) {
        this.node.angle = v;
    }

    /**active */
    @property({ type: cc.Boolean })
    get active(): boolean {
        return this.node.active;
    }
    set active(v: boolean) {
        this.node.active = v;
    }
    /**parent */
    @property({ type: cc.Node })
    get parent(): cc.Node {
        return this.node.parent;
    }
    set parent(v: cc.Node) {
        this.node.parent = v;
    }

    // /**priority */
    // @property({ type: cc.Float})
    // _priority = 1;
    // @property({ type: cc.Float})
    // get priority(): number {
    //     return this._priority;
    // }
    // set priority(v: number) {
    //     this._priority = v;
    // }

    // // 根据优先级priority属性进行子节点排序
    // static updateSiblingIndex(node: cc.Node) {
    //     // console.log('updateSiblingIndex1', node)
    //     node.children.sort((a, b) => {
    //         return gameHelper.addCompOnce(a, Props).priority - gameHelper.addCompOnce(b, Props).priority;
    //     })
    //     // console.log('updateSiblingIndex2', node.children)
    // }
}
window['Props'] = Props;